package com.kmdd.xtds.room

import androidx.room.Dao
import androidx.room.Entity
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.PrimaryKey
import androidx.room.Query
import kotlinx.coroutines.flow.Flow

@Entity(tableName = "blood_sugar")
data class BloodSugar(
    @PrimaryKey(autoGenerate = true) val id: Int = 0, var bloodValue: String,//血糖值
    var bloodHeight: String,//身高
    var timeStamp: Long,//当前日志时间戳
    var bloodWeight: String //体重
)

@Dao
interface BloodSugarDao {

    /**
     * 添加
     */
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun insert(bloodSugar: List<BloodSugar>)

    @Query("SELECT * FROM blood_sugar ORDER BY timeStamp DESC")
    fun queryList(): Flow<List<BloodSugar>?>

}